Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track build file changes #168

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

milesziemer
Copy link
Contributor

This change makes the server register for document lifecycle events like
didChange for build files. Previous behavior was to register for file
system change events for build files, but eventually we want to give
diagnostics, completions, etc. for build files as you type, so we need
to track all changes. This change keeps existing behavior from the
user's perspective, as we still only reload projects on save, so it
serves mostly as a refactor.

I also extracted the state managed by SmithyLanguageServer to its own
class, ServerState, and flattened ProjectManager into that class, so we
can manage the state of the server in a more centralized location.

Depends on #167

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@milesziemer milesziemer force-pushed the track-build-file-changes branch from 019c186 to 0402ac4 Compare October 10, 2024 16:53
This change makes the server register for document lifecycle events like
didChange for build files. Previous behavior was to register for file
system change events for build files, but eventually we want to give
diagnostics, completions, etc. for build files as you type, so we need
to track all changes. This change keeps existing behavior from the
user's perspective, as we still only reload projects on save, so it
serves mostly as a refactor.

I also extracted the state managed by SmithyLanguageServer to its own
class, ServerState, and flattened ProjectManager into that class, so we
can manage the state of the server in a more centralized location.
@milesziemer milesziemer force-pushed the track-build-file-changes branch from 0402ac4 to 9f1e92b Compare October 28, 2024 20:54
@milesziemer milesziemer marked this pull request as ready for review October 28, 2024 20:54
@milesziemer milesziemer requested a review from a team as a code owner October 28, 2024 20:54
@milesziemer milesziemer requested review from kstich and hpmellema and removed request for kstich October 28, 2024 20:54
for (Project project : attachedProjects.values()) {
ProjectFile projectFile = project.getProjectFile(path);
if (projectFile != null) {
detachedProjects.remove(uri);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im a little confused why we remove it from detached projects here? I would have thought that would get checked correctly in the isDetached below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it does, but I'm not calling that method here. I think I meant to end up removing isDetached, but it ended up being too useful. I did some refactoring and pulled the removal logic into the new findAttachedAndRemoveDetached

src/main/java/software/amazon/smithy/lsp/ServerState.java Outdated Show resolved Hide resolved
@milesziemer milesziemer merged commit 3b1ea23 into smithy-lang:main Nov 5, 2024
3 checks passed
yasmewad pushed a commit to yasmewad/smithy-language-server that referenced this pull request Nov 5, 2024
This change makes the server register for document lifecycle events like
didChange for build files. Previous behavior was to register for file
system change events for build files, but eventually we want to give
diagnostics, completions, etc. for build files as you type, so we need
to track all changes. This change keeps existing behavior from the
user's perspective, as we still only reload projects on save, so it
serves mostly as a refactor.

I also extracted the state managed by SmithyLanguageServer to its own
class, ServerState, and flattened ProjectManager into that class, so we
can manage the state of the server in a more centralized location.
milesziemer added a commit to milesziemer/smithy-language-server that referenced this pull request Nov 6, 2024
Fixes a bug in smithy-lang#168 where the server would send the wrong registration
for didSave on Smithy files.
milesziemer added a commit that referenced this pull request Nov 6, 2024
Fixes a bug in #168 where the server would send the wrong registration
for didSave on Smithy files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants